VERSION = @VERSION@
HOSTOS  = @HOSTOS@
HOSTCPU = @HOSTCPU@

LIBDIR = @LIBDIR@
CFGDIR = @CFGDIR@
LOCDIR = @LOCDIR@
DOCDIR = @DOCDIR@

################################################################################

CXX =           @CXX@
HOSTCXX =       @HOSTCXX@
LD =            @CXX_LINK@
HOSTLD =        @HOSTCXX_LINK@
EXEEXT =        @EXEEXT@

DEBUG =         @DEBUG@
GCCDEP =        @GCCDEP@
DEFS =          @DEFS@ \
                -DLIBDIR='"$(LIBDIR)"' \
                -DCFGDIR='"$(CFGDIR)"' \
                -DLOCDIR='"$(LOCDIR)"' \
                -DKDEDIR='"$(KDEDIR)"' \
                -DPACKAGE='"icewm"' \
                -DVERSION='"$(VERSION)"' \
                -DHOSTOS='"$(HOSTOS)"' \
                -DHOSTCPU='"$(HOSTCPU)"' \
                -DEXEEXT='"$(EXEEXT)"' \
                -DICEWMEXE='"icewm$(EXEEXT)"' \
                -DICEWMTRAYEXE='"icewmtray$(EXEEXT)"' \
                -DICEWMBGEXE='"icewmbg$(EXEEXT)"' \
                -DICESMEXE='"icewm-session$(EXEEXT)"' \
                -DICEHELPEXE='"icehelp$(EXEEXT)"' \
                -DICEHELPIDX='"$(DOCDIR)/icewm-$(VERSION)/icewm.html"'

CXXFLAGS =      @CXXFLAGS@ $(DEBUG) $(DEFS) `pkg-config gdk-pixbuf-xlib-2.0 --cflags` \
	        @CORE_CFLAGS@ @IMAGE_CFLAGS@ @AUDIO_CFLAGS@ # `fc-config --cflags`
LFLAGS =	@LDFLAGS@ 
LIBS =          @LIBS@ `pkg-config gdk-pixbuf-xlib-2.0 --libs` 

CORE_LIBS =     @CORE_LIBS@ # `fc-config --libs`
IMAGE_LIBS =    @IMAGE_LIBS@
AUDIO_LIBS =    @AUDIO_LIBS@
GNOME1_LIBS =    @GNOME1_LIBS@
GNOME2_LIBS =    @GNOME2_LIBS@

################################################################################

libybase_OBJS = \
	ref.o \
	mstring.o \
	upath.o \
	misc.o \
	ylocale.o \
	yarray.o \
	\
        yapp.o \
	yconfig.o \
	yprefs.o \
	ysocket.o \
	yworker.o \
	ytimer.o 
        
libycore_OBJS = \
        ypaths.o \
	ypipereader.o \
	ywindow.o \
	ypaint.o \
	ypopup.o \
        ycursor.o \
        ypixbuf.o \
        yxembed.o \
        yfont.o \
	yfontcore.o \
	yfontxft.o \
	yimage.o \
	yimage_gdk.o \
	yxapp.o \
	yurl.o \
	yicon.o \
	ypixmap.o \
	\
        ytooltip.o \
	yparse.o \
	wmconfig.o

libytoolkit_OBJS = \
	ysmapp.o \
	yinput.o \
	ylabel.o \
	ylistbox.o \
	ymenuitem.o \
	ymenu.o \
	ybutton.o \
	yscrollbar.o \
	yscrollview.o
	
genpref_OBJS = \
	genpref.o

applet_OBJS = \
        atasks.o \
	aworkspaces.o \
	amailbox.o \
	aclock.o \
	acpustatus.o \
	apppstatus.o \
	aaddressbar.o \
	objbar.o \
	aapm.o \
	atray.o \
	
taskbar_OBJS = \
	wmtaskbar.o \
	wmwinmenu.o \
	wmabout.o \
	browse.o \
        wmprog.o \
        yxtray.o \
        themes.o \
	$(applet_OBJS)

icewm_LIBS = \
	$(CORE_LIBS) $(IMAGE_LIBS)
icewm_OBJS = \
        wmsession.o \
	wmswitch.o \
	wmstatus.o \
        wmoption.o \
	wmaction.o \
        wmcontainer.o \
	wmclient.o \
        wmmgr.o \
	wmapp.o \
        wmframe.o \
	wmbutton.o \
	wmminiicon.o \
	wmtitle.o \
	movesize.o \
	decorate.o \
	\
	$(taskbar_OBJS) \
	wmwinlist.o \
        wmdialog.o \
	\
        $(libytoolkit_OBJS) $(libycore_OBJS) $(libybase_OBJS) \
        ymsgbox.o \
	ydialog.o \

icesh_LIBS = \
	$(CORE_LIBS)
icesh_OBJS = \
	icesh.o misc.o

icewm-session_LIBS = \
	$(CORE_LIBS)
icewm-session_OBJS = \
	icesm.o $(libybase_OBJS)

icewmhint_LIBS = \
	$(CORE_LIBS)
icewmhint_OBJS = \
	icewmhint.o

icewmbg_LIBS = \
	$(CORE_LIBS) $(IMAGE_LIBS)
icewmbg_OBJS = \
	icewmbg.o $(libybase_OBJS) $(libycore_OBJS)

icesound_LIBS = \
	$(CORE_LIBS) $(AUDIO_LIBS)
icesound_OBJS = \
	icesound.o misc.o ycmdline.o

icewm-menu-gnome1_LIBS = \
	$(CORE_LIBS) $(GNOME1_LIBS)
icewm-menu-gnome1_OBJS = \
	gnome.o misc.o ycmdline.o yarray.o

icewm-menu-gnome2_LIBS = \
	$(CORE_LIBS) $(GNOME2_LIBS)
icewm-menu-gnome2_OBJS = \
	gnome2.o misc.o ycmdline.o yarray.o

icehelp_LIBS = \
	$(CORE_LIBS) $(IMAGE_LIBS)
icehelp_OBJS = \
	$(libytoolkit_OBJS) $(libybase_OBJS) $(libycore_OBJS) icehelp.o

#icecheckmail_LIBS = \
#	$(CORE_LIBS)
#icecheckmail_OBJS = \
#	$(libycore_OBJS) icecheckmail.o yurl.o

iceclock_OBJS = \
	$(libytoolkit_OBJS) $(libybase_OBJS) $(libycore_OBJS) iceclock.o aclock.o
iceclock_LIBS = \
	$(CORE_LIBS) $(IMAGE_LIBS)
icebar_OBJS = \
	$(libytoolkit_OBJS) $(libybase_OBJS) \
        wmtaskbar.o \
        wmprog.o browse.o themes.o wmaction.o \
	amailbox.o aclock.o acpustatus.o apppstatus.o aaddressbar.o objbar.o
icewmtray_OBJS = \
	$(libytoolkit_OBJS) $(libybase_OBJS) $(libycore_OBJS) yxtray.o icetray.o
icewmtray_LIBS = \
	$(CORE_LIBS) $(IMAGE_LIBS)
icesame_OBJS = \
	$(libytoolkit_OBJS) $(libybase_OBJS) $(libycore_OBJS) icesame.o
icesame_LIBS = \
	$(CORE_LIBS) $(IMAGE_LIBS)
icelist_OBJS = \
	$(libytoolkit_OBJS) $(libybase_OBJS) $(libycore_OBJS) icelist.o
icelist_LIBS = \
	$(CORE_LIBS) $(IMAGE_LIBS)
iceview_OBJS = \
	$(libytoolkit_OBJS) $(libybase_OBJS) $(libycore_OBJS) iceview.o
iceview_LIBS = \
	$(CORE_LIBS) $(IMAGE_LIBS)
iceicon_OBJS = \
	$(libytoolkit_OBJS) $(libybase_OBJS) $(libycore_OBJS) iceicon.o
iceicon_LIBS = \
	$(CORE_LIBS) $(IMAGE_LIBS)
icerun_OBJS = \
	$(libytoolkit_OBJS) $(libybase_OBJS) $(libycore_OBJS) icerun.o
icerun_LIBS = \
	$(CORE_LIBS) $(IMAGE_LIBS)
iceskt_OBJS = \
	$(libytoolkit_OBJS) $(libybase_OBJS) $(libycore_OBJS) iceskt.o
testmenus_LIBS = \
	$(CORE_LIBS) $(IMAGE_LIBS) 
testmenus_OBJS = \
	$(libytoolkit_OBJS) $(libybase_OBJS) $(libycore_OBJS) testmenus.o wmprog.o wmaction.o themes.o browse.o
testwinhints_OBJS= \
        testwinhints.o
testwinhints_LIBS = \
        $(CORE_LIBS) $(IMAGE_LIBS)

testnetwmhints_OBJS= \
        testnetwmhints.o
testnetwmhints_LIBS = \
        $(CORE_LIBS) $(IMAGE_LIBS)

testmap_OBJS = \
        testmap.o
testmap_LIBS = \
        $(CORE_LIBS) $(IMAGE_LIBS)

testparse_OBJS = \
        testparse.o $(libice_OBJS)
testparse_LIBS = \
        $(CORE_LIBS) $(IMAGE_LIBS)

testlocale_OBJS = \
	testlocale.o ylocale.o misc.o
testarray_OBJS = \
	testarray.o yarray.o misc.o

################################################################################

APPLICATIONS = @APPLICATIONS@
TESTCASES = @TESTCASES@
OBJECTS = @BASEOBJS@ @TESTOBJS@
BINARIES = @BASEBINS@ @TESTBINS@

################################################################################

all:	base
base:	@BASEBINS@ genpref$(EXEEXT) ../lib/preferences
tests:	@TESTBINS@
clean:
	rm -f $(BINARIES) genpref$(EXEEXT) *.o *.d *~

.PHONY: all base tests clean

################################################################################

%.o: %.cc
	@echo "  CXX     " $@
	@$(CXX) $(CXXFLAGS) $(GCCDEP) -c $<

$(BINARIES):
	@echo "  LD      " $@
	@$(LD) -o $@ $($(@:$(EXEEXT)=)_OBJS) $(LFLAGS) $($(@:$(EXEEXT)=)_LFLAGS) $(LIBS) $($(@:$(EXEEXT)=)_LIBS)

genpref.o: genpref.cc
	@echo "  HOSTCXX " $@
	@$(HOSTCXX) $(CXXFLAGS) $(GCCDEP) -c $<
	
genpref$(EXEEXT):
	@echo "  HOSTLD  " $@
	@$(HOSTLD) -o $@ $(genpref_OBJS)

################################################################################

gnome.o: gnome.cc
	@echo "  CXX     " $@
	@$(CXX) $(CXXFLAGS)  @GNOME1_CFLAGS@ $(GCCDEP) -c $<

gnome2.o: gnome2.cc
	@echo "  CXX     " $@
	@$(CXX) $(CXXFLAGS)  @GNOME2_CFLAGS@ $(GCCDEP) -c $<

################################################################################

#libybase.so: $(libybase_OBJS)
#	-@rm -f $@
#	ld -shared -o $@ $(libybase_OBJS)

wmabout.o: ../VERSION

../lib/preferences: genpref$(EXEEXT)
	@echo "  GENPREF " $@
	@./genpref$(EXEEXT) >../lib/preferences

genpref$(EXEEXT): $(genpref_OBJS)

################################################################################

check:	all tests
	./icewm$(EXEEXT) --help >/dev/null
	./testarray$(EXEEXT)
	./testlocale$(EXEEXT)

################################################################################
#END

